<?php

use App\Controllers\AuthController;
use App\Controllers\StudentController;
use App\Controllers\GradeController;
use App\Controllers\RewardController;
use App\Controllers\PunishmentController;
use App\Controllers\UserController;
use App\Middleware\AuthMiddleware;

// 公开路由 - 不需要认证
$router->post('/auth/login', [AuthController::class, 'login']);

// 需要认证的路由
$router->middleware(AuthMiddleware::class);

// 认证相关
$router->post('/auth/logout', [AuthController::class, 'logout'], true);
$router->get('/auth/current', [AuthController::class, 'current'], true);

// 学生管理
$router->get('/students', [StudentController::class, 'index'], true);
$router->get('/students/majors', [StudentController::class, 'getMajors'], true);
$router->get('/students/classes', [StudentController::class, 'getClasses'], true);
$router->post('/students/import', [StudentController::class, 'import'], true);
$router->get('/students/export', [StudentController::class, 'export'], true);
$router->get('/students/:id', [StudentController::class, 'show'], true);
$router->post('/students', [StudentController::class, 'store'], true);
$router->put('/students/:id', [StudentController::class, 'update'], true);
$router->delete('/students/:id', [StudentController::class, 'destroy'], true);

// 成绩管理
$router->get('/grades', [GradeController::class, 'index'], true);
$router->get('/students/:studentId/grades', [GradeController::class, 'getByStudent'], true);
$router->post('/grades', [GradeController::class, 'store'], true);
$router->put('/grades/:id', [GradeController::class, 'update'], true);
$router->delete('/grades/:id', [GradeController::class, 'destroy'], true);

// 奖励管理
$router->get('/rewards', [RewardController::class, 'index'], true);
$router->get('/students/:studentId/rewards', [RewardController::class, 'getByStudent'], true);
$router->post('/rewards', [RewardController::class, 'store'], true);
$router->put('/rewards/:id', [RewardController::class, 'update'], true);
$router->delete('/rewards/:id', [RewardController::class, 'destroy'], true);

// 惩罚管理
$router->get('/punishments', [PunishmentController::class, 'index'], true);
$router->get('/students/:studentId/punishments', [PunishmentController::class, 'getByStudent'], true);
$router->post('/punishments', [PunishmentController::class, 'store'], true);
$router->put('/punishments/:id', [PunishmentController::class, 'update'], true);
$router->delete('/punishments/:id', [PunishmentController::class, 'destroy'], true);

// 用户管理
$router->get('/users', [UserController::class, 'index'], true);
$router->post('/users', [UserController::class, 'store'], true);
$router->put('/users/:id', [UserController::class, 'update'], true);
$router->delete('/users/:id', [UserController::class, 'destroy'], true);
$router->post('/users/:id/reset-password', [UserController::class, 'resetPassword'], true);

